﻿using System;
using System.Windows;
using System.Windows.Data;
using System.Windows.Media;
using Skyper.Data;
using Skyper.Model;
using Skyper.View;
using Skyper.View.Chat;
namespace Skyper.Presenters {
	public class ChatItemPresenter : Presenter<IChatItemView,ChatModel> {

		#region Nested
		public class HeaderPresenter : Presenter<IChatHeaderView, ContactModel> {
			#region Constructor
			public HeaderPresenter(IChatHeaderView view, ContactModel model)
				: base(view, model) {

			}
			#endregion
			#region Public
			public sealed override void Refresh() {
				this.View.Description = this.Model.Mood;
				this.View.Title = this.Model.FriendlyName;
				this.View.ImageSource = AvatarConverter.Convert(this.Model.Avatar) as ImageSource;
			}
			#endregion
		}
		#endregion
		#region Fields
		private HeaderPresenter headerPresenter;
		#endregion
		#region Constructor
		public ChatItemPresenter(IChatItemView view, ChatModel model)
			: base(view, model) {


				this.View.Loaded += (View_Loaded);
				this.View.Unloaded += (View_Unloaded);

		}
		#endregion
		#region Private
		private void View_Unloaded(object sender, RoutedEventArgs e) {

		}
		private void View_Loaded(object sender, RoutedEventArgs e) {
			this.View.ContentView = new ChatContentView();
			this.View.HeaderView = new ChatHeaderView();

			this.headerPresenter = new HeaderPresenter(this.View.HeaderView, this.Model.Contact);
		}
		#endregion
	}
}
